<!doctype html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="copyright" content="www.infoearth.com" />
    <title></title>
    <link rel="stylesheet" href="lib/jquery.mobile-1.4.5/jquery.mobile-1.4.5.min.css">
    <script src="lib/jquery.mobile-1.4.5/jquery.min.js"></script>
    <script src="lib/jquery.mobile-1.4.5/jquery.mobile-1.4.5.min.js"></script>
    <script src="lib/config.js"></script>
    <script src="lib/common.js"></script>
    <style>
    html {
        height: 100%;
        background-color: #fff;
    }

    body {
        background-color: #fff;
        padding: 0;
        margin: 0;
        display: -webkit-box;
        display: -webkit-flex;
        display: flex;
        height: 100%;
        -webkit-box-orient: vertical;
        -webkit-flex-flow: column;
        flex-flow: column;
    }
    </style>
</head>

<body>
    <div>
        <div style="margin-top:30px;">
            <img src="image/logo.png" />
        </div>
        <div style="margin:10px 10px;">
            <div style="margin: 10px 10px;">
                <label for="tbUserName">用户名：</label>
                <input id="tbUserName" type="text" value="" data-clear-btn="true">
                <label for="tbPwd">密码：</label>
                <input id="tbPwd" type="Password" value="" data-clear-btn="true">
            </div>
            <div style="margin: 20px 10px;">
                <input type="button" value="登录" id="btnLogin">
            </div>
            <div style="margin: 20px 10px;">
                <label>
                    <input type="checkbox" id="chkSavePwd" checked=""> 记住密码 </label>
            </div>
        </div>
    </div>
</body>
<script type="text/javascript" src="script/api.js"></script>
<script type="text/javascript">
apiready = function() {
    //获取用户信息（记住用户名的情况)
    var userInfo = getCookie('yjdcUserInfo');
    if (userInfo != null && userInfo != '') {
        var strList = userInfo.split('#');
        $("#tbUserName").val(strList[0]);
        if (strList[1] != '') {
            $("#tbPwd").val(strList[1]);
            $("#chkSavePwd").attr("checked", true);
        } else
            $("#chkSavePwd").attr("checked", false);
    }
    // $("#btnLogin").click(function() {
    // 	var userName = $("#tbUserName").val();
    // 	var pwd = $("#tbPwd").val();
    // 	var savePwd = $('#chkSavePwd').is(':checked');
    // 	if (userName == '' || pwd == '') {
    // 		showMsg("请输入用户名密码！");
    // 		return;
    // 	}
    // 	var state = Login(userName, pwd);
    // 	if (state == false) {
    // 		showMsg("用户名密码有误！");
    // 		return;
    // 	}
    // 	if (savePwd == true) {
    // 		setCookie('yjdcUserInfo', userName + "#" + pwd);
    // 	} else {
    // 		setCookie('yjdcUserInfo', userName + "#" + '');
    // 	}
    // 	api.openWin({
    // 		name : 'main',
    // 		url : 'html/main.html'
    // 	});
    // });
    $("#btnLogin").click(function() {
      	var userName = $("#tbUserName").val();
      	var pwd = $("#tbPwd").val();
        if($('#chkSavePwd').is(':checked')){
          setCookie('yjdcUserInfo', userName + "#" + pwd);
        }
        api.openWin({
            name: 'main',
            url: 'html/main.html'
        });
    });
}

function Login(userName, pwd) {
    api.showProgress({
        style: 'default',
        animationType: 'fade',
        title: '正在登录中',
        text: '请稍等...',
        modal: false
    });
    //登录df平台，生成token
    var state = loginUser(userName, pwd);
    //验证用户是否是群测群防员
    api.hideProgress();
    return state;
}
</script>

</html>
